package tech.aistar.coontroller;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.aistar.pojo.Product;
import tech.aistar.pojo.Result;
import tech.aistar.service.ProductService;

import javax.swing.*;
import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {
    //controller层调用service层,声明service
    @Autowired
    private ProductService productService;

    @GetMapping("{pageNum}/{pageSize}")
    public Result index(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize){
        PageInfo<Product> pageInfo = productService.page(pageNum,pageSize);
        return Result.success(pageInfo);
    }
}
